const Router = require('koa-router');
const koaPath = require('path');
const fs = require('fs');
const { nextApp } = require('../server');
let router = new Router();
const appDirectory = fs.realpathSync(process.cwd());
router.get('*', async (ctx, next) => {
  let { req, res, path } = ctx;
  await nextApp.serveStatic(
    req,
    res,
    koaPath.resolve(appDirectory, '.' + path.replace(/^\/\_/, '/.'))
  );
});
module.exports = router.routes();
